In [2]:
    
%matplotlib inline
    
In [3]:
    
import skprocrustes as skp
import time
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
    
In [4]:
    
gkbsolver = skp.GKBSolver(verbose=0)
spgsolver = skp.SPGSolver(verbose=0)
gpisolver = skp.GPISolver(verbose=0)
ebsolver = skp.EBSolver(verbose=0)
gbbsolver = skp.GBBSolver(verbose=0)
gkbgbbsolver = skp.GKBSolver(verbose=0, inner_solver='gbb')
gkbblobopsolver = skp.GKBSolver(verbose=0, bloboptest = True)
    
In [5]:
    
problem1 = skp.ProcrustesProblem((500,500,10,10), problemnumber=1)
    
In [7]:
    
t0 = time.time(); results1_gkb = gkbsolver.solve(problem1); t1_gkb = time.time()-t0
t0 = time.time(); results1_spg = spgsolver.solve(problem1); t1_spg = time.time()-t0
t0 = time.time(); results1_gpi = gpisolver.solve(problem1); t1_gpi = time.time()-t0
t0 = time.time(); results1_eb = ebsolver.solve(problem1); t1_eb = time.time()-t0
t0 = time.time(); results1_gbb = gbbsolver.solve(problem1); t1_gbb = time.time()-t0
t0 = time.time(); results1_gkbgbb = gkbgbbsolver.solve(problem1); t1_gkbgbb = time.time()-t0
t0 = time.time(); results1_gkbblobop = gkbblobopsolver.solve(problem1); t1_gkbblobop = time.time()-t0
    
In [12]:
    
gkb, spg, gpi, eb, gbb, gkbgbb, gkbblobop = plt.bar([0,1,2,3,4,5,6], [t1_gkb, t1_spg, t1_gpi, t1_eb, t1_gbb, t1_gkbgbb, t1_gkbblobop])
gkb.set_facecolor('r')
spg.set_facecolor('g')
gpi.set_facecolor('b')
eb.set_facecolor('m')
gbb.set_facecolor('y')
gkbgbb.set_facecolor('k')
gkbblobop.set_facecolor('c')
ax = plt.gca()
ax.set_xticks([0,1,2,3,4,5,6])
ax.set_xticklabels(['GKB', 'SPG', 'GPI', 'EB', 'GBB', 'GKB+GBB', 'BLOBOP'])
#ax.set_ylim([0, 100])
ax.set_ylabel('CPU Time')
ax.set_title('Problem 1')
    
    Out[12]:
    
In [13]:
    
gkb, spg, gpi, gbb, gkbgbb, gkbblobop = plt.bar([0,1,2,3,4,5], [t1_gkb, t1_spg, t1_gpi, t1_gbb, t1_gkbgbb, t1_gkbblobop])
gkb.set_facecolor('r')
spg.set_facecolor('g')
gpi.set_facecolor('b')
gbb.set_facecolor('y')
gkbgbb.set_facecolor('k')
gkbblobop.set_facecolor('c')
ax = plt.gca()
ax.set_xticks([0,1,2,3,4,5])
ax.set_xticklabels(['GKB', 'SPG', 'GPI', 'GBB', 'GKB+GBB', 'BLOBOP'])
#ax.set_ylim([0, 100])
ax.set_ylabel('CPU Time')
ax.set_title('Problem 1')
    
    Out[13]:
    
In [14]:
    
results = pd.DataFrame({'GKB' : [t1_gkb], 
                        'SPG' : [t1_spg], 
                        'GPI' : [t1_gpi], 
                        'EB' : [t1_eb], 
                        'GBB' : [t1_gbb], 
                        'GKB+GBB' : [t1_gkbgbb],
                        'GKB+BLOBOP': [t1_gkbblobop]}, index=['problem1'])
results = results.T
results
    
    Out[14]:
In [15]:
    
problem2 = skp.ProcrustesProblem((100,100,5,5), problemnumber=2)
    
In [16]:
    
t0 = time.time(); results2_gkb = gkbsolver.solve(problem2); t2_gkb = time.time()-t0
t0 = time.time(); results2_spg = spgsolver.solve(problem2); t2_spg = time.time()-t0
t0 = time.time(); results2_gpi = gpisolver.solve(problem2); t2_gpi = time.time()-t0
t0 = time.time(); results2_eb = ebsolver.solve(problem2); t2_eb = time.time()-t0
t0 = time.time(); results2_gbb = gbbsolver.solve(problem2); t2_gbb = time.time()-t0
t0 = time.time(); results2_gkbgbb = gkbgbbsolver.solve(problem2); t2_gkbgbb = time.time()-t0
t0 = time.time(); results2_gkbblobop = gkbblobopsolver.solve(problem2); t2_gkbblobop = time.time()-t0
    
In [17]:
    
gkb, spg, gpi, eb, gbb = plt.bar([0,1,2,3,4], [t2_gkb, t2_spg, t2_gpi, t2_eb, t2_gbb])
gkb.set_facecolor('r')
spg.set_facecolor('g')
gpi.set_facecolor('b')
eb.set_facecolor('m')
gbb.set_facecolor('y')
#gkbgbb.set_facecolor('k')
ax = plt.gca()
ax.set_xticks([0,1,2,3,4])
ax.set_xticklabels(['GKB', 'SPG', 'GPI', 'EB', 'GBB'])
#ax.set_ylim([0, 100])
ax.set_ylabel('CPU Time')
ax.set_title('Problem 2')
gkb, spg, gpi, eb, gbb, gkbgbb, gkbblobop = plt.bar([0,1,2,3,4,5,6], [t2_gkb, t2_spg, t2_gpi, t2_eb, t2_gbb, t2_gkbgbb, t2_gkbblobop])
gkb.set_facecolor('r')
spg.set_facecolor('g')
gpi.set_facecolor('b')
eb.set_facecolor('m')
gbb.set_facecolor('y')
gkbgbb.set_facecolor('k')
gkbblobop.set_facecolor('c')
ax = plt.gca()
ax.set_xticks([0,1,2,3,4,5,6])
ax.set_xticklabels(['GKB', 'SPG', 'GPI', 'EB', 'GBB', 'GKB+GBB', 'BLOBOP'])
#ax.set_ylim([0, 100])
ax.set_ylabel('CPU Time')
ax.set_title('Problem 2')
    
    Out[17]:
    
In [18]:
    
results['problem2'] = pd.Series([t2_gkb, t2_spg, t2_gpi, t2_eb, t2_gbb, t2_gkbgbb, t2_gkbblobop], index=results.index)
results
    
    Out[18]:
In [23]:
    
problem3 = skp.ProcrustesProblem((500, 500, 5, 5), problemnumber=3)
    
In [24]:
    
t0 = time.time(); results3_gkb = gkbsolver.solve(problem3); t3_gkb = time.time()-t0
results3_gkb.show()
    
    
In [25]:
    
t0 = time.time(); results3_spg = spgsolver.solve(problem3); t3_spg = time.time()-t0; print(t3_spg)
    
    
In [26]:
    
results3_spg.show()
    
    
In [27]:
    
t0 = time.time(); results3_gpi = gpisolver.solve(problem3); t3_gpi = time.time()-t0; print(t3_gpi)
    
    
In [28]:
    
results3_gpi.show()
    
    
In [29]:
    
t0 = time.time(); results3_eb = ebsolver.solve(problem3); t3_eb = time.time()-t0; print(t3_eb)
    
    
In [30]:
    
results3_eb.show()
    
    
In [31]:
    
t0 = time.time(); results3_gbb = gbbsolver.solve(problem3); t3_gbb = time.time()-t0; print(t3_gbb)
    
    
In [32]:
    
results3_gbb.show()
    
    
In [33]:
    
gkb, spg, gpi, eb, gbb = plt.bar([0,1,2,3,4], [t3_gkb, t3_spg, t3_gpi, t3_eb, t3_gbb])
gkb.set_facecolor('r')
spg.set_facecolor('g')
gpi.set_facecolor('b')
eb.set_facecolor('m')
gbb.set_facecolor('y')
ax = plt.gca()
ax.set_xticks([0,1,2,3,4])
ax.set_xticklabels(['GKB', 'SPG', 'GPI', 'EB', 'GBB'])
#ax.set_ylim([0, 100])
ax.set_ylabel('CPU Time')
ax.set_title('Problem 3')
    
    Out[33]:
    
In [34]:
    
results['problem3'] = pd.Series([t3_gkb, t3_spg, t3_gpi, t3_eb, t3_gbb, 0], index=results.index)
results
    
    Out[34]:
In [35]:
    
gkbsolver_blobop = skp.GKBSolver(verbose=0, bloboptest = True)
    
In [36]:
    
t0 = time.time(); results1_gkbblobop = gkbsolver_blobop.solve(problem1); t1_blobop = time.time()-t0
    
In [37]:
    
results1_gkbblobop.show()
    
    
In [38]:
    
results1_gkb.show()
    
    
In [39]:
    
gkb, blobop = plt.bar([0,1], [t1_gkb, t1_blobop])
gkb.set_facecolor('r')
blobop.set_facecolor('y')
ax = plt.gca()
ax.set_xticks([0,1])
ax.set_xticklabels(['GKB', 'BLOBOP'])
#ax.set_ylim([0, 100])
ax.set_ylabel('CPU Time')
ax.set_title('Problem 1')
    
    Out[39]:
    
In [40]:
    
gkb, spg, gpi, eb, gbb, blobop = plt.bar([0,1,2,3,4,5], [t1_gkb, t1_spg, t1_gpi, t1_eb, t1_gbb, t1_blobop])
gkb.set_facecolor('r')
spg.set_facecolor('g')
gpi.set_facecolor('b')
eb.set_facecolor('m')
gbb.set_facecolor('y')
blobop.set_facecolor('k')
ax = plt.gca()
ax.set_xticks([0,1,2,3,4,5])
ax.set_xticklabels(['GKB', 'SPG', 'GPI', 'EB', 'GBB', 'BLOBOP'])
#ax.set_ylim([0, 100])
ax.set_ylabel('CPU Time')
ax.set_title('Problem 1')
    
    Out[40]:
    
In [41]:
    
gkb, spg, gpi, gbb, blobop = plt.bar([0,1,2,3,4], [t1_gkb, t1_spg, t1_gpi, t1_gbb, t1_blobop])
gkb.set_facecolor('r')
spg.set_facecolor('g')
gpi.set_facecolor('b')
#eb.set_facecolor('m')
gbb.set_facecolor('y')
blobop.set_facecolor('k')
ax = plt.gca()
ax.set_xticks([0,1,2,3,4])
ax.set_xticklabels(['GKB', 'SPG', 'GPI', 'GBB', 'BLOBOP'])
#ax.set_ylim([0, 100])
ax.set_ylabel('CPU Time')
ax.set_title('Problem 1')
    
    Out[41]:
    
In [42]:
    
t0 = time.time(); results2_gkbblobop = gkbsolver_blobop.solve(problem2); t2_blobop = time.time()-t0
    
In [43]:
    
results2_gkbblobop.show()
    
    
In [44]:
    
results2_gkb.show()
    
    
In [45]:
    
gkb, blobop = plt.bar([0,1], [t2_gkb, t2_blobop])
gkb.set_facecolor('r')
blobop.set_facecolor('y')
ax = plt.gca()
ax.set_xticks([0,1])
ax.set_xticklabels(['GKB', 'BLOBOP'])
#ax.set_ylim([0, 100])
ax.set_ylabel('CPU Time')
ax.set_title('Problem 2')
    
    Out[45]:
    
In [46]:
    
gkb, spg, gpi, eb, blobop = plt.bar([0,1,2,3,4], [t2_gkb, t2_spg, t2_gpi, t2_eb, t2_blobop])
gkb.set_facecolor('r')
spg.set_facecolor('g')
gpi.set_facecolor('b')
eb.set_facecolor('m')
blobop.set_facecolor('y')
ax = plt.gca()
ax.set_xticks([0,1,2,3,4])
ax.set_xticklabels(['GKB', 'SPG', 'GPI', 'EB', 'BLOBOP'])
#ax.set_ylim([0, 100])
ax.set_ylabel('CPU Time')
ax.set_title('Problem 2')
    
    Out[46]:
    
In [47]:
    
t0 = time.time(); results3_gkbblobop = gkbsolver_blobop.solve(problem3); t3_blobop = time.time()-t0
    
In [48]:
    
results3_gkbblobop.show()
    
    
In [49]:
    
results3_gkb.show()
    
    
In [50]:
    
gkb, blobop = plt.bar([0,1], [t3_gkb, t3_blobop])
gkb.set_facecolor('r')
blobop.set_facecolor('y')
ax = plt.gca()
ax.set_xticks([0,1])
ax.set_xticklabels(['GKB', 'BLOBOP'])
#ax.set_ylim([0, 100])
ax.set_ylabel('CPU Time')
ax.set_title('Problem 3')
    
    Out[50]:
    
In [51]:
    
gkb, spg, gpi, eb, blobop = plt.bar([0,1,2,3,4], [t3_gkb, t3_spg, t3_gpi, t3_eb, t3_blobop])
gkb.set_facecolor('r')
spg.set_facecolor('g')
gpi.set_facecolor('b')
eb.set_facecolor('m')
blobop.set_facecolor('y')
ax = plt.gca()
ax.set_xticks([0,1,2,3,4])
ax.set_xticklabels(['GKB', 'SPG', 'GPI', 'EB', 'BLOBOP'])
#ax.set_ylim([0, 100])
ax.set_ylabel('CPU Time')
ax.set_title('Problem 3')
    
    Out[51]:
    
In [52]:
    
r = pd.DataFrame({'problem1' : t1_blobop, 'problem2' : t2_blobop, 'problem3' : t3_blobop}, index=['BLOBOP'])
results = results.append(r)
results
    
    Out[52]:
In [53]:
    
gkbpolar = skp.GKBSolver(verbose=0, polar="ns")
gkbpolarblobop = skp.GKBSolver(verbose=0, polar="ns", bloboptest=True)
    
In [54]:
    
t0 = time.time(); results1_gkbpolar = gkbpolar.solve(problem1); t1_gkbpolar = time.time()-t0
    
In [55]:
    
results1_gkbpolar.show()
    
    
In [56]:
    
t0 = time.time(); results1_gkbpolarblobop = gkbpolarblobop.solve(problem1); t1_gkbpolarblobop = time.time()-t0
    
In [57]:
    
results1_gkbpolarblobop.show()
    
    
In [58]:
    
gkb, polarblobop, polar = plt.bar([0,1,2], [t1_gkb, t1_gkbpolarblobop, t1_gkbpolar])
gkb.set_facecolor('r')
polarblobop.set_facecolor('g')
polar.set_facecolor('b')
ax = plt.gca()
ax.set_xticks([0,1,2])
ax.set_xticklabels(['GKB', 'POLAR+BLOBOP', 'POLAR'])
#ax.set_ylim([0, 100])
ax.set_ylabel('CPU Time')
ax.set_title('Problem 1')
    
    Out[58]:
    
In [59]:
    
t0 = time.time(); results2_gkbpolar = gkbpolar.solve(problem2); t2_gkbpolar = time.time()-t0
    
In [60]:
    
results2_gkbpolar.show()
    
    
In [61]:
    
t0 = time.time(); results2_gkbpolarblobop = gkbpolarblobop.solve(problem2); t2_gkbpolarblobop = time.time()-t0
    
In [62]:
    
results2_gkbpolarblobop.show()
    
    
In [63]:
    
gkb, polarblobop, polar = plt.bar([0,1,2], [t2_gkb, t2_gkbpolarblobop, t2_gkbpolar])
gkb.set_facecolor('r')
polarblobop.set_facecolor('g')
polar.set_facecolor('b')
ax = plt.gca()
ax.set_xticks([0,1,2])
ax.set_xticklabels(['GKB', 'POLAR+BLOBOP', 'POLAR'])
#ax.set_ylim([0, 100])
ax.set_ylabel('CPU Time')
ax.set_title('Problem 2')
    
    Out[63]:
    
In [64]:
    
t0 = time.time(); results3_gkbpolar = gkbpolar.solve(problem3); t3_gkbpolar = time.time()-t0
    
In [65]:
    
results3_gkbpolar.show()
    
    
In [66]:
    
t0 = time.time(); results3_gkbpolarblobop = gkbpolarblobop.solve(problem3); t3_gkbpolarblobop = time.time()-t0
    
In [67]:
    
results3_gkbpolarblobop.show()
    
    
In [68]:
    
gkb, polarblobop, polar = plt.bar([0,1,2], [t3_gkb, t3_gkbpolarblobop, t3_gkbpolar])
gkb.set_facecolor('r')
polarblobop.set_facecolor('g')
polar.set_facecolor('b')
ax = plt.gca()
ax.set_xticks([0,1,2])
ax.set_xticklabels(['GKB', 'POLAR+BLOBOP', 'POLAR'])
#ax.set_ylim([0, 100])
ax.set_ylabel('CPU Time')
ax.set_title('Problem 3')
    
    Out[68]:
    
In [69]:
    
r = pd.DataFrame({'problem1' : t1_gkbpolar, 'problem2' : t2_gkbpolar, 'problem3' : t3_gkbpolar}, index=['POLAR'])
results = results.append(r)
r = pd.DataFrame({'problem1' : t1_gkbpolarblobop, 'problem2' : t2_gkbpolarblobop, 'problem3' : t3_gkbpolarblobop}, index=['POLAR+BLOBOP'])
results = results.append(r)
results
    
    Out[69]:
In [70]:
    
gkb, blobop, polarblobop, polar, spg, gpi, eb = plt.bar([0, 1, 2, 3, 4, 5, 6], [t1_gkb, t1_blobop, t1_gkbpolarblobop, t1_gkbpolar, t1_spg, t1_gpi, t1_eb])
gkb.set_facecolor('r')
blobop.set_facecolor('k')
polarblobop.set_facecolor('g')
polar.set_facecolor('b')
spg.set_facecolor('y')
gpi.set_facecolor('m')
eb.set_facecolor('c')
ax = plt.gca()
ax.set_xticks([0,1,2,3,4,5,6])
ax.set_xticklabels(['GKB', 'BLOBOP', 'POLAR+BLOBOP', 'POLAR', 'SPG', 'GPI', 'EB'])
#ax.set_ylim([0, 100])
ax.set_ylabel('CPU Time')
ax.set_title('Problem 1')
    
    Out[70]:
    
In [71]:
    
gkb, blobop, polarblobop, polar, spg, gpi, eb = plt.bar([0, 1, 2, 3, 4, 5, 6], [t2_gkb, t2_blobop, t2_gkbpolarblobop, t2_gkbpolar, t2_spg, t2_gpi, t2_eb])
gkb.set_facecolor('r')
blobop.set_facecolor('k')
polarblobop.set_facecolor('g')
polar.set_facecolor('b')
spg.set_facecolor('y')
gpi.set_facecolor('m')
eb.set_facecolor('c')
ax = plt.gca()
ax.set_xticks([0,1,2,3,4,5,6])
ax.set_xticklabels(['GKB', 'BLOBOP', 'POLAR+BLOBOP', 'POLAR', 'SPG', 'GPI', 'EB'])
#ax.set_ylim([0, 100])
ax.set_ylabel('CPU Time')
ax.set_title('Problem 2')
    
    Out[71]:
    
In [72]:
    
gkb, blobop, polarblobop, polar, spg, gpi, eb = plt.bar([0, 1, 2, 3, 4, 5, 6], [t3_gkb, t3_blobop, t3_gkbpolarblobop, t3_gkbpolar, t3_spg, t3_gpi, t3_eb])
gkb.set_facecolor('r')
blobop.set_facecolor('k')
polarblobop.set_facecolor('g')
polar.set_facecolor('b')
spg.set_facecolor('y')
gpi.set_facecolor('m')
eb.set_facecolor('c')
ax = plt.gca()
ax.set_xticks([0,1,2,3,4,5,6])
ax.set_xticklabels(['GKB', 'BLOBOP', 'POLAR+BLOBOP', 'POLAR', 'SPG', 'GPI', 'EB'])
#ax.set_ylim([0, 100])
ax.set_ylabel('CPU Time')
ax.set_title('Problem 3')
    
    Out[72]:
    
In [ ]: